package com.bestv.bsr.controller;

import com.bestv.bsr.core.annotations.Sign;
import com.bestv.bsr.core.context.RecommendContext;
import com.bestv.bsr.core.entities.params.BsrRequestParams;
import com.bestv.bsr.core.entities.vo.RecDataVo;
import com.bestv.bsr.core.service.BsrManageService;
import com.bestv.bsr.core.utils.ValidateUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author taojiacheng
 */
@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/api")
public class RecommendController {

    private final BsrManageService bsrManageService;

    @Sign
    @RequestMapping("/recommend")
    public RecDataVo recommend(BsrRequestParams requestParams) {
        // 参数校验
        ValidateUtils.validated(requestParams);
        RecommendContext recommendContext = bsrManageService.initRecommendContext(requestParams);
        return bsrManageService.doRecommend(recommendContext);
    }

}
